﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ERP_RORZE_DLL.Product.DAO;
using ERP_RORZE_DLL.Product.database;

namespace ERP_RORZE.Product.Quotation
{
    public partial class ctrlQuotationMachine : DevExpress.XtraEditors.XtraUserControl
    {
        ClsQuationDAO clsQuationDAO = new ClsQuationDAO();
        DataTable dt;
        Qmachine b = new Qmachine();

        public ctrlQuotationMachine()
        {
            InitializeComponent();
        }

        void Reload(object sender, EventArgs e)
        {
            dt = clsQuationDAO.GetAllQuotationMachine();
            gridControl1.DataSource = dt;

        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frm_QmachineAdd frmAdd = new frm_QmachineAdd();
            frmAdd.Reload += new EventHandler(Reload);
            frmAdd.Show();
        }

        private void ctrlQuotationMachine_Load(object sender, EventArgs e)
        {
            Reload(sender, e);
        }

        private void btnReload_Click(object sender, EventArgs e)
        {
            Reload(sender, e);
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            b.RecordNo = int.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "RecordNo").ToString());
            clsQuationDAO.DeleteQuotationMachine(b);
            Reload(sender, e);
        }

        private void btnEdit_Click(object sender, EventArgs e)
        {
            frm_QmachineEdit frmEdit = new frm_QmachineEdit();
            frmEdit.ClampTime = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ClampTime").ToString();
            frmEdit.InputDate = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "InputDate").ToString();
            frmEdit.MachineID = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MachineID").ToString();
            frmEdit.MPartNo = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MPartNo").ToString();
            frmEdit.Note = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Note").ToString();
            frmEdit.OptionID = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "OptionID").ToString();
            frmEdit.ProTime = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ProTime").ToString();
            frmEdit.QuotationID = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "QuotationID").ToString();
            frmEdit.RecordNo = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "RecordNo").ToString();
            frmEdit.StaffID = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "StaffID").ToString();
            frmEdit.Reload += new EventHandler(Reload);
            frmEdit.Show();
        }
    }
}
